<?php

/**
 * 用户辅助
 *
 * Created by PhpStorm.
 * User: evan
 * Date: 16/9/19
 * Time: 下午4:56
 */
class Helper extends MY_Api_Controller
{
    /**
     * 用户技能标签
     */
    public function user_skill_tag()
    {
        $uid = $this->uid;


        $this->load->service('user/service_user_helper');
        $data = $this->service_user_helper->user_skill_tag($uid);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 添加用户技能标签
     */
    public function add_user_skill_tag()
    {
        $uid       = $this->uid;
        $name      = trim($this->input->get_post('name'));
        $by_module = (int)$this->input->get_post('by_module');


        $this->load->service('user/service_user_helper');
        $data = $this->service_user_helper->add_user_skill_tag($uid, $name, $by_module);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 用户反馈
     */
    public function feedback()
    {
        $uid    = $this->uid;
        $remind = trim($this->input->get_post('remind'));
        $fid    = (int)$this->input->get_post('fid');


        $this->load->service('user/service_user_helper');
        $data = $this->service_user_helper->feedback($uid, $remind, $fid);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 邀请好友
     */
    public function invite()
    {
        $uid   = $this->uid;


        $this->load->service('user/service_user_helper');
        $data = $this->service_user_helper->invite($uid);


        /*
        $tmp_data = $data['data']['invite_log'];
        $data['data']['invite_log'] = array();
        foreach ($tmp_data as $k => $v)
        {
            $data['data']['invite_log'][] = array
            (
                'uid'      => $v['to_uid'],
                'uname'    => $v['to_uname'],
                'nickname' => $v['nickname'],
                'reward'   => $v['reward'],
            );
        }
        //*/


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 加载更多邀请日志
     */
    public function load_more_invite_log()
    {
        $uid   = $this->uid;
        $page  = (int)$this->input->get_post('page');


        $this->load->service('user/service_user_helper');
        $data = $this->service_user_helper->load_more_invite_log($uid, $page);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 添加用户附加资料
     */
    public function add_user_attach()
    {
        $uid = $this->uid;
        $fid = (int)$this->input->get_post('fid');


        $this->load->service('user/service_user_helper');
        $data = $this->service_user_helper->add_user_attach($uid, $fid);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 获取用户附加资料
     */
    public function get_user_attach()
    {
        $uid = $this->uid;


        $this->load->service('user/service_user_helper');
        $data = $this->service_user_helper->get_user_attach($uid);


        $this->json_output($data['data'], $data['status']);
    }


    /**
     * 删除用户附加资料
     */
    public function delete_user_attach()
    {
        $uid = $this->uid;
        $fid = (int)$this->input->get_post('fid');


        $this->load->service('user/service_user_helper');
        $data = $this->service_user_helper->delete_user_attach($uid, $fid);


        $this->json_output($data['data'], $data['status']);
    }
}